package com.testMvc;

import com.alibaba.fastjson.JSONObject;
import com.core.netty.http.work.HttpMyReponse;
import com.core.netty.http.work.HttpMyRequest;
import com.core.springmvc.MyController;
import com.core.springmvc.MyRequestMapping;

import java.io.IOException;
import java.util.*;

@MyController
@MyRequestMapping("/myMvcTest")
public class myMvcTest {

    @MyRequestMapping("getStudentList")
    public void getStudentList(HttpMyRequest req, HttpMyReponse rep, String abc) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        Random random = new Random();
        for (int i = 1; i < 5; i++) {
            Map<String, Object> map = new HashMap<>();
            int ran = random.nextInt(1) + 1;
            map.put("id", i);
            map.put("name", "小明" + i);
            if (1 == ran) {
                map.put("sex", "男");
            } else {
                map.put("sex", "女");
            }
            list.add(map);
        }

        //throw new RuntimeException("你是个ab");
        //rep.write("你是个王八");
        rep.write(JSONObject.toJSONString(list));
    }
}
